public class T {


public static void fun(Message<? extends Fruit> temp){
//temp.setMessage(new Banana()); //仍然无法修改！
//temp.setMessage(new Apple()); //仍然无法修改！
    Fruit b = temp.getMessage();
    System.out.println(b);
}

}



class Food {
    public void show(){
        System.out.println("食物");
    }
}
class Fruit extends Food {
    public void show(){
        System.out.println("水果");
    }

}
class Apple extends Fruit {
    public void show(){
        System.out.println("苹果");
    }
}
class Banana extends Fruit {
    public void show(){
        System.out.println("香蕉");
    }
}

class Plate<T> {
    private T plate ;
    public T getPlate() {
        return plate;
    }
    public void setPlate(T plate) {
        this.plate = plate;
    }
}



 class TestDemo {
    public static void main(String[] args) {
        Plate<Fruit> plate1 = new Plate<>();
        plate1.setPlate(new Fruit());

        fun(plate1);
        Plate<Food> plate2 = new Plate<>();
        plate2.setPlate(new Food());
        fun(plate2);
    }

    public static void fun(Plate<? super Fruit> temp) {
// 此时可以修改！！添加的是Fruit 或者Fruit的子类
        temp.setPlate(new Apple());//这个是Fruit的子类
        temp.setPlate(new Fruit());//这个是Fruit的本身
//Fruit fruit = temp.getPlate(); 不能接收，这里无法确定是哪个父类
        System.out.println(temp.getPlate());//只能直接输出
    }
}